//
//  XYHomeViewCtrl.m
//  OC_weibo
//
//  Created by 李旭阳 on 16/1/7.
//  Copyright © 2016年 apple. All rights reserved.
//

#import "XYHomeViewCtrl.h"
#import "XYTitleButton.h"
#import "XYTempCtrl1.h"
#import "XYPopMenuView.h"

@implementation XYHomeViewCtrl

-(void)viewDidLoad{
    [super viewDidLoad];
    
    [self setNav];
}

#pragma mark 导航栏
-(void)setNav{
    
    self.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithImageName:@"navigationbar_friendsearch" target:self action:@selector(friendsearch)];
    self.navigationItem.rightBarButtonItem = [UIBarButtonItem itemWithImageName:@"navigationbar_pop" target:self action:@selector(pop)];
    
    XYTitleButton *titleBtn = [[XYTitleButton alloc] init];
    
    [titleBtn setTitle:@"我叫首页" forState:UIControlStateNormal];
    [titleBtn setImage:[UIImage imageNamed:@"navigationbar_arrow_down"] forState:UIControlStateNormal];
    
    //设置文字颜色
    [titleBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [titleBtn sizeToFit];
    
    self.navigationItem.titleView = titleBtn;
    
    //点击事件
    [titleBtn addTarget:self action:@selector(titleButtonClick:) forControlEvents:UIControlEventTouchUpInside];

}

#pragma mark 点击事件的方法
-(void)titleButtonClick:(XYTitleButton *)button{
    UIView *customView = [[UIView alloc] initWithFrame:CGRectMake(5, 12, 100, 100)];
    customView.backgroundColor = [UIColor redColor];
    
    //加载pop页面
    XYPopMenuView *popMenuView = [[XYPopMenuView alloc] initWithCustomView:customView];
    [popMenuView showWithView:button];
}

- (void)friendsearch{
    XYTempCtrl1 *Ctrl = [[XYTempCtrl1 alloc] init];
    [self.navigationController pushViewController:Ctrl animated:YES];
}

- (void)pop{
    NSLog(@"%s",__func__);
}


@end
